home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / util / sys / 68040Lib.lha / 68040Lib / Autodocs / fpsp.doc < prev   
Text File  |  1999-12-12  |  10KB  |  253 lines

  1. TABLE OF CONTENTS
  2.  
  3. fpsp.resource/--Background--
  4. fpsp.resource/FPSPMonadic
  5. fpsp.resource/FPSPDyadic
  6.  
  7. fpsp.resource/--Background--                    fpsp.resource/--Background--
  8.  
  9.     PURPOSE
  10.  
  11.         This resource contains the emulation routines for FPU instructions
  12.         which are non-native for the 68040 or the 68060 processor.
  13.         This resource is - as all resources - not disk based. Instead, it
  14.         is build by the 68040 or 68060.library on startup. The CPU driver
  15.         libraries install the "FPSP" code as part of their initialization
  16.         process, such that every non-impelemented FPU instruction will be
  17.         emulated properly. However, this means that for every such 
  18.         instruction, the CPU has to go thru exception processing, and will
  19.         therefore stop multitasking when emulating a non-implemented in-
  20.         struction. Calling the fpsp routines directly thru the new
  21.         fpsp.resource will prevent this overhead and will gain some speed.
  22.         
  23.         A separate patch - the FastIEEE program - will patch the system
  24.         math libraries to make use of this resource.        
  25.  
  26.         The fpsp.resource is re-entrant, interrupt-callable code. The
  27.         resource offers only two functions which emulate monadic resp.
  28.         dyadic functions of the 68881/68882 FPU on a 68040 FPU.
  29.  
  30.         Currently, only the V40 68040.library builds and provides this
  31.         resource, future versions of the 68060.library might offer this
  32.         as well.
  33.  
  34.         These functions are designed to be stub functions for assembly
  35.         language, they are not designed to be callable from C or any
  36.         other high-level language. Typical applications would call these
  37.         routines indirectly thru a link library which provides all
  38.         requires parameters. Direct calling from within application
  39.         programs is not desired.
  40.  
  41.         Moreover, the FPSP routines *do not* generate FPU exceptions them-
  42.         selves for speed reasons. If this is desired, the calling routine 
  43.         has to check the fpcr and the fpsr FPU registers manually and
  44.         has to generate the exceptions itself.
  45.  
  46. fpsp.resource/FPSPMonadic                        fpsp.resource/FPSPMonadic
  47.  
  48.     NAME
  49.         FPSPMonadic        -    emulate a monadic 68881/68882 instruction
  50.  
  51.     SYNOPSIS
  52.         storeflag = FPSPMonadic ( opword, operand );
  53.         d0                            d0        fp0
  54.  
  55.         BYTE FPUControl ( UWORD , IEEEExtended );
  56.  
  57.     FUNCTION
  58.         This function emulates the 68881/68882 monadic instruction 
  59.         passed in in register d0, and performs the desired mathematical
  60.         operation on FP0. It returns the result in the FPU register FP0 
  61.         and FP1.
  62.  
  63.     INPUTS
  64.         opword        -    The extension word of a valid 68881/68882 
  65.                         instruction. Valid extension words are found in
  66.                         the motorola family guide or the 68881/68882
  67.                         manual.
  68.                         Note that this is actually the SECOND (!) opword
  69.                         of the 68881/68882 instruction.
  70.                         The bits of the opword have to be specified as
  71.                         follows:
  72.  
  73.                         Bits 15 and 13 must be cleared. The fpsp.resource
  74.                         does not emulate FPU control instructions.
  75.  
  76.                         R/M:    Source operand mode,     bit 14.
  77.                                 Must be set to zero.
  78.                         Source:    Source specifier,         bits 12 to 10.
  79.                                 Must be set to zero.
  80.                         Dest:    Destination specifier,    bits 9 to 7.
  81.                                 Must be set to zero.
  82.                         Inst:    Instruction field,        bits 5 to 0.
  83.                                 Must be filled with the opcode of the
  84.                                 desired instruction, see the motorola
  85.                                 documents for the list. For the special
  86.                                 case of FPSINCOS, the FPC field, bits
  87.                                 2 to 0, has to be set to 001 to encode
  88.                                 FP1 as secondary result register.
  89.  
  90.         operand        -    A valid IEEE extended precision number as argument
  91.                         to the function to be performed.
  92.  
  93.         Secondary inputs are delivered in the FPU registers FPCR and FPSR,
  94.         namely to select the rounding precision and the behaiviour in case
  95.         of invalid arguments or infinite results.
  96.  
  97.     RESULTS
  98.         storeflag    -    This is set to 0 in case the FPSP routine could
  99.                         generate a result. THIS DOES NOT MEAN that the
  100.                         arguments are valid. In case all exceptions are
  101.                         disabled, the storeflag will always be returned as
  102.                         zero, but the result might be infinite or a NAN.
  103.  
  104.         Secondary results are delivered in the FPU registers FP0, FP1 and
  105.         FPSR.
  106.  
  107.         FP0 contains the (primary) result of the 68881/68882 instruction
  108.         in case the storeflag is 0. *IT MIGHT WELL BE A NAN OR AN INF*
  109.  
  110.         In case the storeflag is non-zero, FP0 is undefined and the FPSP
  111.         routines indicate that an exception should be generated by the
  112.         caller. This happens only if an exception condition was detected
  113.         and the corresponding exception has been enabled in the FPCR 
  114.         passed in. In all other cases a NAN or a INF will be returned
  115.         and the storeflag will indicate a valid result.
  116.  
  117.         FP1 contains a secondary result, if any. The only case were FP1
  118.         is used is the FSINCOS instruction where the sine is returned in
  119.         FP0 and the cosine in FP1. Otherwise undefined.
  120.  
  121.         FPSR contains the FPU status similar to what a real 68881/68882 
  122.         would have returned. 
  123.  
  124.     NOTES
  125.         This function should not be called directly. It should either be
  126.         called by the system math libraries, or by compiler link libaries.
  127.  
  128.         Note that a non-zero store flag indicates that an exception 
  129.         condition was detected. NOTE THAT THE FPSP CODE DOES NOT CAUSE
  130.         AN EXCEPTION ITSELF. It is the responsibility of the caller to
  131.         check the FPSR, the FPCR and the storeflag to generate this
  132.         exception itself, if desireable. In case the storeflag is non-
  133.         zero, no useful result is returned in FP0 or FP1.
  134.  
  135.         Useful instruction opwords can be found in the motorola 
  136.         documentation, either the MC68K family guide, or in the 68881/
  137.         68882 manual.
  138.  
  139.         This function does not require a6 to be loaded with the FPSP 
  140.         resource base. It is interrupt-callable.
  141.  
  142.     BUGS
  143.  
  144.     SEE ALSO
  145.         libraries/68040.library, FPSPDyadic,
  146.         the Motorola 68881/68882 manual, the MC68K family guide.
  147.  
  148. fpsp.resource/FPSPDyadic                        fpsp.resource/FPSPDyadic
  149.  
  150.     NAME
  151.         FPSPDyadic        -    emulate a dyadic 68881/68882 instruction
  152.  
  153.     SYNOPSIS
  154.         storeflag = FPSPMonadic ( opword, operand1, operand2 );
  155.         d0                            d0        fp0        fp1
  156.  
  157.         BYTE FPUControl ( UWORD , IEEEExtended , IEEEExtended );
  158.  
  159.     FUNCTION
  160.         This function emulates the 68881/68882 dyadic instruction 
  161.         passed in in register d0, and performs the desired mathematical
  162.         operation on FP0 and FP1. It returns the result in the FPU 
  163.         register FP0.
  164.  
  165.     INPUTS
  166.         opword        -    The extension word of a valid 68881/68882 
  167.                         instruction. Valid extension words are found in
  168.                         the motorola family guide or the 68881/68882
  169.                         manual.
  170.                         Note that this is actually the SECOND (!) opword
  171.                         of the 68881/68882 instruction.
  172.                         The bits of the opword have to be specified as
  173.                         follows:
  174.  
  175.                         Bits 15 and 13 must be cleared. The fpsp.resource
  176.                         does not emulate FPU control instructions.
  177.  
  178.                         R/M:    Source operand mode,     bit 14.
  179.                                 Must be set to zero.
  180.                         Source:    Source specifier,         bits 12 to 10.
  181.                                 Must be set to zero.
  182.                         Dest:    Destination specifier,    bits 9 to 7.
  183.                                 Must be set to zero.
  184.                         Inst:    Instruction field,        bits 5 to 0.
  185.                                 Must be filled with the opcode of the
  186.                                 desired instruction, see the motorola
  187.                                 documents for the list. For the special
  188.                                 case of FPSINCOS, the FPC field, bits
  189.                                 2 to 0, has to be set to 001 to encode
  190.                                 FP1 as secondary result register.
  191.  
  192.         operand1    -    A valid IEEE extended precision number as argument
  193.                         to the function to be performed. This is the source
  194.                         operand of dyadic instructions.
  195.  
  196.         operand2    -    The destination operand of the dyadic 68881/68882
  197.                         instructions.
  198.  
  199.         Secondary inputs are delivered in the FPU registers FPCR and FPSR,
  200.         namely to select the rounding precision and the behaiviour in case
  201.         of invalid arguments or infinite results.
  202.  
  203.     RESULTS
  204.         storeflag    -    This is set to 0 in case the FPSP routine could
  205.                         generate a result. THIS DOES NOT MEAN that the
  206.                         arguments are valid. In case all exceptions are
  207.                         disabled, the storeflag will always be returned as
  208.                         zero, but the result might be infinite or a NAN.
  209.  
  210.         Secondary results are delivered in the FPU registers FP0, FP1 and
  211.         FPSR.
  212.  
  213.         FP0 contains the (primary) result of the 68881/68882 instruction
  214.         in case the storeflag is 0. *IT MIGHT WELL BE A NAN OR AN INF*
  215.  
  216.         In case the storeflag is non-zero, FP0 is undefined and the FPSP
  217.         routines indicate that an exception should be generated by the
  218.         caller. This happens only if an exception condition was detected
  219.         and the corresponding exception has been enabled in the FPCR 
  220.         passed in. In all other cases a NAN or a INF will be returned
  221.         and the storeflag will indicate a valid result.
  222.  
  223.         FP1 contains a secondary result, if any. As there is currently no
  224.         dyadic opcode with a secondary result, this register should be
  225.         ignored.
  226.  
  227.         FPSR contains the FPU status similar to what a real 68881/68882 
  228.         would have returned. 
  229.  
  230.     NOTES
  231.         This function should not be called directly. It should either be
  232.         called by the system math libraries, or by compiler link libaries.
  233.  
  234.         Note that a non-zero store flag indicates that an exception 
  235.         condition was detected. NOTE THAT THE FPSP CODE DOES NOT CAUSE
  236.         AN EXCEPTION ITSELF. It is the responsibility of the caller to
  237.         check the FPSR, the FPCR and the storeflag to generate this
  238.         exception itself, if desireable. In case the storeflag is non-
  239.         zero, no useful result is returned in FP0 or FP1.
  240.  
  241.         Useful instruction opwords can be found in the motorola 
  242.         documentation, either the MC68K family guide, or in the 68881/
  243.         68882 manual.
  244.  
  245.         This function does not require a6 to be loaded with the FPSP 
  246.         resource base. It is interrupt-callable.
  247.  
  248.     BUGS
  249.  
  250.     SEE ALSO
  251.         libraries/68040.library, FPSPMonadic,
  252.         the Motorola 68881/68882 manual, the MC68K family guide.
  253.